import { useReducer } from 'react';
import { reducer, Context } from './reducer';
import { Link } from 'umi';

function A() {
  const [store, dispatch] = useReducer(reducer, window.defaultState); //创建reducer

  return (
    // 通过 state传递上下文 状态
    <Context.Provider value={{ store, dispatch }}>
      page2-{store.total}
      <button onClick={() => dispatch({ type: 'add' })}>+1</button>
      <Link to="./page1">page1</Link>
    </Context.Provider>
  );
}
export default A;
